package com.tencent.examples.core.temp;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mongodb.BasicDBObject;
import com.tencent.bk.utils.blueking.tools.DateTimeUtils;
import com.tencent.bk.utils.blueking.tools.StringConverters;
import com.tencent.examples.blueking.extend.QueryParam;
import com.tencent.examples.blueking.mongo.model.ObjectBase;
import com.tencent.examples.blueking.mongo.service.HostBaseService;
import com.tencent.examples.blueking.mongo.service.ObjectBaseService;
import com.tencent.examples.core.processor.common.CommParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

@Controller
@RequestMapping("/web/admin/shopInfo")
public class shopInfoAction {
    @Autowired
    CommParams commParams;

    @Autowired
    ObjectBaseService objectBaseService;

    @Autowired
    HostBaseService hostBaseService;

    @RequestMapping("/getDockerInfo")
    @ResponseBody
    public JSONObject getDockerInfo(HttpServletRequest request) {

        JSONObject hostObjectTotal = new JSONObject();
        JSONArray count = new JSONArray();

        //主机总数：以下统计对HostBase进行
        Map<String, String> hostTotalMap = new HashMap<>();
        JSONObject countHostObject = new JSONObject();
//        cloudTotalMap.put("bk_obj_id", "server_cloud");
        Long hostTotal = hostBaseService.getHostTotal(hostTotalMap);
        countHostObject.put("name", "当前主机总数");
        countHostObject.put("value", hostTotal);
        count.add(countHostObject);

        //docker总数
        Map<String, String> dockerTotalMap = new HashMap<>();
        JSONObject countDockerObject = new JSONObject();
        dockerTotalMap.put("bk_obj_id", "host");
        dockerTotalMap.put("server_type", "5");
        Long dockerTotal = hostBaseService.getHostTotal(dockerTotalMap);
        countDockerObject.put("name", "当前Docker总数");
        countDockerObject.put("value", dockerTotal);
        count.add(countDockerObject);

        //宿主机总数
        Map<String, String> suTotalMap = new HashMap<>();
        JSONObject suObject = new JSONObject();
        suTotalMap.put("bk_obj_id", "host");
        suTotalMap.put("server_type", "5");
        Long suTotal = hostBaseService.getHostTotal(suTotalMap);
        suObject.put("name", "当前宿主机总数");
        suObject.put("value", suTotal);
        count.add(suObject);

        //虚拟机总数
        Map<String, String> vnTotalMap = new HashMap<>();
        JSONObject countVnObject = new JSONObject();
        vnTotalMap.put("bk_obj_id", "host");
        vnTotalMap.put("server_type", "3");
        Long vnTotal = hostBaseService.getHostTotal(vnTotalMap);
        countVnObject.put("name", "当前虚拟机总数");
        countVnObject.put("value", vnTotal);
        count.add(countVnObject);

        //云主机总数
        Map<String, String> cloudTotalMap = new HashMap<>();
        JSONObject countCloudObject = new JSONObject();
        cloudTotalMap.put("bk_obj_id", "host");
        cloudTotalMap.put("server_type", "4");
        Long cloudTotal = hostBaseService.getHostTotal(cloudTotalMap);
        countCloudObject.put("name", "当前云主机总数");
        countCloudObject.put("value", cloudTotal);
        count.add(countCloudObject);

        //物理机总数
        Map<String, String> vMTotalMap = new HashMap<>();
        JSONObject vMCloudObject = new JSONObject();
        vMTotalMap.put("bk_obj_id", "host");
        vMTotalMap.put("server_type", "1");
        Long vMTotal = hostBaseService.getHostTotal(vMTotalMap);
        vMCloudObject.put("name", "当前物理机总数");
        vMCloudObject.put("value", vMTotal);
        count.add(vMCloudObject);

        hostObjectTotal.put("count", count);

        JSONObject graphic = new JSONObject();


        //饼状图
        JSONArray pie = new JSONArray();

        //SLA级别统计
        JSONObject SLAObject = new JSONObject();
        SLAObject.put("title", "SLA级别统计");
        JSONArray SLAArray = new JSONArray();
        List SLAList = new ArrayList();
        SLAList.add("1");
        SLAList.add("2");
        SLAList.add("3");
        JSONObject SLAObjectInfo = new JSONObject();
        SLAObjectInfo.put("1", "L1");
        SLAObjectInfo.put("2", "L2");
        SLAObjectInfo.put("3", "L3");
        for (int k = 0; k < SLAList.size(); k++) {
            JSONObject dataSLA = new JSONObject();
            Map<String, String> SLAMapInfo = new HashMap<>();
            SLAMapInfo.put("bk_sla", SLAList.get(k).toString());
            Long total = hostBaseService.getHostTotal(SLAMapInfo);
            dataSLA.put("name", SLAObjectInfo.getString(SLAList.get(k).toString()));
            dataSLA.put("value", total);
            SLAArray.add(dataSLA);
        }
        SLAObject.put("data", SLAArray);
        pie.add(SLAObject);
        graphic.put("pie", pie);

        //ISP统计
//        JSONObject ISPObject=new JSONObject();
//        ISPObject.put("title","运营商统计");
//        JSONArray ISPArray=new JSONArray();
//        List ISPList=new ArrayList();
//        ISPList.add("0");
//        ISPList.add("1");
//        ISPList.add("2");
//        ISPList.add("3");
//        JSONObject ISPObjectInfo=new JSONObject();
//        ISPObjectInfo.put("0","其他");
//        ISPObjectInfo.put("1","电信");
//        ISPObjectInfo.put("2","联通");
//        ISPObjectInfo.put("3","移动");
//        for (int k=0;k<ISPList.size();k++){
//            JSONObject dataISP=new JSONObject();
//            Map<String,String> ISPMapInfo=new HashMap<>();
//            ISPMapInfo.put("bk_isp_name",ISPList.get(k).toString());
//            Long total=hostBaseService.getHostTotal(ISPMapInfo);
//            dataISP.put("name",ISPObjectInfo.getString(ISPList.get(k).toString()));
//            dataISP.put("value",total);
//            ISPArray.add(dataISP);
//        }
//        ISPObject.put("data",ISPArray);
//        pie.add(ISPObject);
//        graphic.put("pie",pie);

        //OS类型统计
        JSONObject OSObject = new JSONObject();
        OSObject.put("title", "操作系统类型统计");
        JSONArray OSArray = new JSONArray();
        List OSList = new ArrayList();
        OSList.add("Linux");
        OSList.add("Windows");
        OSList.add("CentOS");
        OSList.add("Vmware");
        for (int k = 0; k < OSList.size(); k++) {
            JSONObject dataOS = new JSONObject();
            Map<String, String> OSMapInfo = new HashMap<>();
            OSMapInfo.put("bk_os_name", OSList.get(k).toString());
            Long total = hostBaseService.getHostTotal(OSMapInfo);
            dataOS.put("name", OSList.get(k));
            dataOS.put("value", total);
            OSArray.add(dataOS);
        }
        OSObject.put("data", OSArray);
        pie.add(OSObject);
        graphic.put("pie", pie);

        //环境统计
        JSONObject EnvObject = new JSONObject();
        EnvObject.put("title", "环境统计");
        JSONArray EnvArray = new JSONArray();
        List EnvList = new ArrayList();
        EnvList.add("1");
        EnvList.add("2");
        EnvList.add("3");
        EnvList.add("4");
        EnvList.add("5");
        EnvList.add("6");
        JSONObject EnvObjectInfo = new JSONObject();
        EnvObjectInfo.put("1", "PROD");
        EnvObjectInfo.put("2", "UAT");
        EnvObjectInfo.put("3", "DEV");
        EnvObjectInfo.put("4", "PRE");
        EnvObjectInfo.put("5", "QA");
        EnvObjectInfo.put("6", "INT");
        EnvObjectInfo.put("7", "STAG");
        for (int k = 0; k < EnvList.size(); k++) {
            JSONObject dataEnv = new JSONObject();
            Map<String, String> EnvMapInfo = new HashMap<>();
            EnvMapInfo.put("com_evn", EnvList.get(k).toString());
            Long total = hostBaseService.getHostTotal(EnvMapInfo);
            dataEnv.put("name", EnvObjectInfo.getString(EnvList.get(k).toString()));
            dataEnv.put("value", total);
            EnvArray.add(dataEnv);
        }
        EnvObject.put("data", EnvArray);
        pie.add(EnvObject);
        graphic.put("pie", pie);

        //状态统计
        JSONObject StatusObject = new JSONObject();
        StatusObject.put("title", "状态统计");
        JSONArray StatusArray = new JSONArray();
        List StatusList = new ArrayList();
        StatusList.add("1");
        StatusList.add("2");
        StatusList.add("3");
        StatusList.add("4");
        JSONObject StatusObjectInfo = new JSONObject();
        StatusObjectInfo.put("1", "Online");
        StatusObjectInfo.put("2", "Online_unmoni");
        StatusObjectInfo.put("3", "Maintain");
        StatusObjectInfo.put("4", "Offline");
        for (int k = 0; k < StatusList.size(); k++) {
            JSONObject dataStatus = new JSONObject();
            Map<String, String> StatusMapInfo = new HashMap<>();
            StatusMapInfo.put("com_status", StatusList.get(k).toString());
            Long total = hostBaseService.getHostTotal(StatusMapInfo);
            dataStatus.put("name", StatusObjectInfo.getString(StatusList.get(k).toString()));
            dataStatus.put("value", total);
            StatusArray.add(dataStatus);
        }
        StatusObject.put("data", StatusArray);
        pie.add(StatusObject);
        graphic.put("pie", pie);


        //柱状图
        JSONArray line = new JSONArray();
        JSONArray lineBlock = new JSONArray();
        //1、业务top10
        JSONObject netinterIspTypeObjectNew = new JSONObject();
        netinterIspTypeObjectNew.put("title", "业务Top10");
        JSONArray netinterIspTypeArray = new JSONArray();
        List netinterIspTypeTypeList = new ArrayList();
        String a = "2,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,287";
        for (int b = 0; b < a.split(",").length; b++) {
            netinterIspTypeTypeList.add(a.split(",")[b]);
        }
        for (int m = 0; m < netinterIspTypeTypeList.size(); m++) {
            JSONObject datanetinterIspTypeType = new JSONObject();
            Map<String, String> netinterIspTypeMapInfo = new HashMap<>();
            netinterIspTypeMapInfo.put("bk_obj_id", "host");
            netinterIspTypeMapInfo.put("com_app_id", netinterIspTypeTypeList.get(m).toString());
            Long total = hostBaseService.getHostTotal(netinterIspTypeMapInfo);
            datanetinterIspTypeType.put("name", netinterIspTypeTypeList.get(m).toString());
            datanetinterIspTypeType.put("value", total);
            netinterIspTypeArray.add(datanetinterIspTypeType);
        }
        netinterIspTypeObjectNew.put("data", netinterIspTypeArray);
        lineBlock.add(netinterIspTypeObjectNew);

        graphic.put("line", line);
        graphic.put("lineBlock", lineBlock);
        hostObjectTotal.put("graphic", graphic);

        return hostObjectTotal;
    }

    /**
     * 星巴克门店主页
     */
    @RequestMapping("/getStarbucksInfo")
    @ResponseBody
    public JSONObject getStarbucksInfo(HttpServletRequest request) {
        JSONObject shopObjectTotal = new JSONObject();
        JSONArray count = new JSONArray();
        JSONObject countObjectShop = new JSONObject();
        //门店总数
        Map<String, String> shopTotalMap = new HashMap<>();
        shopTotalMap.put("bk_obj_id", "sbux_store_info");
        Long shopTotal = objectBaseService.getTotal(shopTotalMap);
        countObjectShop.put("name", "当前门店总数");
        countObjectShop.put("value", shopTotal);
        count.add(countObjectShop);

        //无监控门店
        Map<String, String> storeMonitorMap = new HashMap<>();
        JSONObject storeMonitorObject = new JSONObject();
        storeMonitorMap.put("bk_obj_id", "sbux_store_info");
        storeMonitorMap.put("store_monitor", "6002");
        Long alreadyMonitor = objectBaseService.getTotal(storeMonitorMap);
        storeMonitorObject.put("name", "无监控门店");
        storeMonitorObject.put("value", alreadyMonitor);
        count.add(storeMonitorObject);

        //新店总数
        Map<String, String> newShopMap = new HashMap<>();
        JSONObject newShopObject = new JSONObject();
        newShopMap.put("bk_obj_id", "new_store");
        Long newShopTotal = objectBaseService.getTotal(newShopMap);
        newShopObject.put("name", "新店总数");
        newShopObject.put("value", newShopTotal);
        count.add(newShopObject);

        //断电门店
        Map<String, String> outAgeMap = new HashMap<>();
        JSONObject outAgeObject = new JSONObject();
        outAgeMap.put("bk_obj_id", "store_problem");
        outAgeMap.put("spower_status", "3001");
        Long outAgeShopTotal = objectBaseService.getTotal(outAgeMap);
        outAgeObject.put("name", "断电门店");
        outAgeObject.put("value", outAgeShopTotal);
        count.add(outAgeObject);

        //断网门店
        Map<String, String> wireNetMap = new HashMap<>();
        JSONObject wireNetObject = new JSONObject();
        wireNetMap.put("bk_obj_id", "store_problem");
        wireNetMap.put("snet_status", "4001");
        Long wireNetTotal = objectBaseService.getTotal(wireNetMap);
        wireNetObject.put("name", "断网门店");
        wireNetObject.put("value", wireNetTotal);
        count.add(wireNetObject);
        //加入数据结构
        shopObjectTotal.put("count", count);

        //饼状图与柱状图
        JSONObject graphic = new JSONObject();
        //饼状图
        JSONArray pie = new JSONArray();

        //1、门店区域统计
        JSONObject qyObject = new JSONObject();
        qyObject.put("title", "门店区域统计");
        JSONArray qyArray = new JSONArray();
        //获取区域信息
        List<ObjectBase> objectBaseList = objectBaseService.getQyInfo("qy");
        //遍历区域信息，并查询当前区域下的所有门店
        for (int j = 0; j < objectBaseList.size(); j++) {
            JSONObject data = new JSONObject();
            ObjectBase objectBase = objectBaseList.get(j);
            Map<String, String> shopMapInfo = new HashMap<>();
            shopMapInfo.put("bk_obj_id", "sbux_store_info");
            shopMapInfo.put("region_en", objectBase.getBk_inst_name());
            Long total = objectBaseService.getTotal(shopMapInfo);
            data.put("name", objectBase.getBk_inst_name());
            data.put("value", total);
            qyArray.add(data);
        }
        qyObject.put("data", qyArray);
        pie.add(qyObject);

        //2、门店类型统计
        JSONObject typeObject = new JSONObject();
        typeObject.put("title", "门店类型统计");
        JSONArray typeArray = new JSONArray();
        List typeList = new ArrayList();
        typeList.add("7001");
        typeList.add("7002");
        typeList.add("7003");
        typeList.add("7004");
        typeList.add("7005");
        JSONObject typeObjectInfo = new JSONObject();
        typeObjectInfo.put("7001", "Core");
        typeObjectInfo.put("7002", "Flagship");
        typeObjectInfo.put("7003", "Reserve");
        typeObjectInfo.put("7004", "HPP");
        typeObjectInfo.put("7005", "R+");
        for (int k = 0; k < typeList.size(); k++) {
            JSONObject dataType = new JSONObject();
            Map<String, String> shopMapInfo = new HashMap<>();
            shopMapInfo.put("bk_obj_id", "sbux_store_info");
            shopMapInfo.put("store_type", typeList.get(k).toString());
            Long total = objectBaseService.getTotal(shopMapInfo);
            dataType.put("name", typeObjectInfo.getString(typeList.get(k).toString()));
            dataType.put("value", total);
            typeArray.add(dataType);
        }
        typeObject.put("data", typeArray);
        pie.add(typeObject);

        //3、门店状态统计
        JSONObject storeStatusObject = new JSONObject();
        storeStatusObject.put("title", "门店状态统计");
        JSONArray storeStatusArray = new JSONArray();
        List storeStatusList = new ArrayList();
        storeStatusList.add("5001");
        storeStatusList.add("5002");
        storeStatusList.add("5003");
        storeStatusList.add("5004");
        JSONObject storeStatusObjectInfo = new JSONObject();
        storeStatusObjectInfo.put("5001", "正常营业");
        storeStatusObjectInfo.put("5002", "装修");
        storeStatusObjectInfo.put("5003", "临时闭店");
        storeStatusObjectInfo.put("5004", "永久闭店");
        for (int k = 0; k < storeStatusList.size(); k++) {
            JSONObject storeStatusDataType = new JSONObject();
            Map<String, String> storeStatusMapInfo = new HashMap<>();
            storeStatusMapInfo.put("bk_obj_id", "sbux_store_info");
            storeStatusMapInfo.put("store_status", storeStatusList.get(k).toString());
            Long total = objectBaseService.getTotal(storeStatusMapInfo);
            storeStatusDataType.put("name", storeStatusObjectInfo.getString(storeStatusList.get(k).toString()));
            storeStatusDataType.put("value", total);
            storeStatusArray.add(storeStatusDataType);
        }
        storeStatusObject.put("data", storeStatusArray);
        pie.add(storeStatusObject);

        //4、计算门店状态统计
        JSONObject opsStatusObject = new JSONObject();
        opsStatusObject.put("title", "计算门店状态");
        JSONArray opsStatusArray = new JSONArray();
        List opsStatusList = new ArrayList();
        opsStatusList.add("已开店");
        opsStatusList.add("未开店");
        opsStatusList.add("临时闭店");
        opsStatusList.add("永久闭店");
        for (int k = 0; k < opsStatusList.size(); k++) {
            JSONObject dataopsStatus = new JSONObject();
            Map<String, String> shopMapInfo = new HashMap<>();
            shopMapInfo.put("bk_obj_id", "sbux_store_info");
            shopMapInfo.put("ops_status", opsStatusList.get(k).toString());
            Long total = objectBaseService.getTotal(shopMapInfo);
            dataopsStatus.put("name", opsStatusList.get(k).toString());
            dataopsStatus.put("value", total);
            opsStatusArray.add(dataopsStatus);
        }
        opsStatusObject.put("data", opsStatusArray);
        pie.add(opsStatusObject);

        graphic.put("pie", pie);
        shopObjectTotal.put("graphic", graphic);

        //柱状图
        JSONArray line = new JSONArray();

        //1、门店装修状态
        JSONObject renovationObject = new JSONObject();
        renovationObject.put("title", "门店装修状态");
        JSONArray renovationArray = new JSONArray();
        List renovationTypeList = new ArrayList();
        renovationTypeList.add("4001");
        renovationTypeList.add("4002");
        renovationTypeList.add("4003");
        JSONObject renovationTypeObject = new JSONObject();
        renovationTypeObject.put("4001", "计划装修");
        renovationTypeObject.put("4002", "正在装修");
        renovationTypeObject.put("4003", "装修完成开业");
        for (int m = 0; m < renovationTypeList.size(); m++) {
            JSONObject dataRenovationType = new JSONObject();
            Map<String, String> shopMapInfo = new HashMap<>();
            shopMapInfo.put("bk_obj_id", "reno_store");
            shopMapInfo.put("renovation_type", renovationTypeList.get(m).toString());
            Long total = objectBaseService.getTotal(shopMapInfo);
            dataRenovationType.put("name", renovationTypeObject.getString(renovationTypeList.get(m).toString()));
            dataRenovationType.put("value", total);
            renovationArray.add(dataRenovationType);
        }
        renovationObject.put("data", renovationArray);
        line.add(renovationObject);

        //2、闭店门店状态
        JSONObject closeShopObject = new JSONObject();
        closeShopObject.put("title", "闭店门店状态");
        JSONArray closeShopArray = new JSONArray();
        List closeShopTypeList = new ArrayList();
        closeShopTypeList.add("4001");
        closeShopTypeList.add("4002");
        closeShopTypeList.add("4003");
        JSONObject closeShopTypeObject = new JSONObject();
        closeShopTypeObject.put("4001", "计划永久闭店");
        closeShopTypeObject.put("4002", "提前永久闭店");
        closeShopTypeObject.put("4003", "临时闭店");
        for (int m = 0; m < closeShopTypeList.size(); m++) {
            JSONObject datacloseShopType = new JSONObject();
            Map<String, String> closeShopMapInfo = new HashMap<>();
            closeShopMapInfo.put("bk_obj_id", "store_close");
            closeShopMapInfo.put("sclose_status", closeShopTypeList.get(m).toString());
            Long total = objectBaseService.getTotal(closeShopMapInfo);
            datacloseShopType.put("name", closeShopTypeObject.getString(closeShopTypeList.get(m).toString()));
            datacloseShopType.put("value", total);
            closeShopArray.add(datacloseShopType);
        }
        closeShopObject.put("data", closeShopArray);
        line.add(closeShopObject);

        //3、门店内网线路类型
        JSONObject netinterIspObject = new JSONObject();
        netinterIspObject.put("title", "门店内网线路类型");
        JSONArray netinterIspArray = new JSONArray();
        List netinterIspTypeList = new ArrayList();
        netinterIspTypeList.add("210001");
        netinterIspTypeList.add("210002");
        netinterIspTypeList.add("210003");
        netinterIspTypeList.add("210004");
        JSONObject netinterIspTypeObject = new JSONObject();
        netinterIspTypeObject.put("210001", "光纤");
        netinterIspTypeObject.put("210002", "铜线");
        netinterIspTypeObject.put("210003", "物业线路");
        netinterIspTypeObject.put("210004", "MPLS");
        for (int m = 0; m < netinterIspTypeList.size(); m++) {
            JSONObject datanetinterIspType = new JSONObject();
            Map<String, String> netinterIspMapInfo = new HashMap<>();
            netinterIspMapInfo.put("bk_obj_id", "sbux_store_info");
            netinterIspMapInfo.put("netinter_isp", netinterIspTypeList.get(m).toString());
            Long total = objectBaseService.getTotal(netinterIspMapInfo);
            datanetinterIspType.put("name", netinterIspTypeObject.getString(netinterIspTypeList.get(m).toString()));
            datanetinterIspType.put("value", total);
            netinterIspArray.add(datanetinterIspType);
        }
        netinterIspObject.put("data", netinterIspArray);
        line.add(netinterIspObject);

        //4、门店内网运营商类型
        JSONObject netinterIspTypeObjectNew = new JSONObject();
        netinterIspTypeObjectNew.put("title", "门店内网运营商类型");
        JSONArray netinterIspTypeArray = new JSONArray();
        List netinterIspTypeTypeList = new ArrayList();
        netinterIspTypeTypeList.add("410001");
        netinterIspTypeTypeList.add("410002");
        netinterIspTypeTypeList.add("410003");
        netinterIspTypeTypeList.add("410004");
        JSONObject netinterIspTypeTypeObject = new JSONObject();
        netinterIspTypeTypeObject.put("410001", "中国电信");
        netinterIspTypeTypeObject.put("410002", "中国联通");
        netinterIspTypeTypeObject.put("410003", "中国移动");
        netinterIspTypeTypeObject.put("410004", "长城宽带");
        for (int m = 0; m < netinterIspTypeTypeList.size(); m++) {
            JSONObject datanetinterIspTypeType = new JSONObject();
            Map<String, String> netinterIspTypeMapInfo = new HashMap<>();
            netinterIspTypeMapInfo.put("bk_obj_id", "sbux_store_info");
            netinterIspTypeMapInfo.put("netinter_isp_type", netinterIspTypeTypeList.get(m).toString());
            Long total = objectBaseService.getTotal(netinterIspTypeMapInfo);
            datanetinterIspTypeType.put("name", netinterIspTypeTypeObject.getString(netinterIspTypeTypeList.get(m).toString()));
            datanetinterIspTypeType.put("value", total);
            netinterIspTypeArray.add(datanetinterIspTypeType);
        }
        netinterIspTypeObjectNew.put("data", netinterIspTypeArray);
        line.add(netinterIspTypeObjectNew);

        //5、预计开店门店-实际开店门店
        QueryParam queryParam = new QueryParam();
        JSONObject title = new JSONObject();

        queryParam.getSqlMap().put("bk_obj_id", "sbux_store_info");
        queryParam.getSqlMap().put("open_startDate", "2012-01-01 00:00:00");
        queryParam.getSqlMap().put("open_endDate", DateTimeUtils.formatDateToStringWithTime(new Date()));
        List<BasicDBObject> o = objectBaseService.getAggregation1(queryParam);
        QueryParam queryParam1 = new QueryParam();
        queryParam1.getSqlMap().put("bk_obj_id", "sbux_store_info");
        queryParam1.getSqlMap().put("plan_startDate", "2012-01-01 00:00:00");
        queryParam.getSqlMap().put("plan_endDate", DateTimeUtils.formatDateToStringWithTime(new Date()));
        List<BasicDBObject> o1 = objectBaseService.getAggregation1(queryParam1);
        JSONArray jsonArray = new JSONArray();
        List<JSONObject> jsonObjectList = new ArrayList<>();

        for (Object object : o1) {
            String province = ((BasicDBObject) object).get("province").toString();
            Integer count1 = StringConverters.ToInteger(((BasicDBObject) object).get("count").toString());
            for (Object objectLow : o) {
                String provinceLow = ((BasicDBObject) objectLow).get("province").toString();
                Integer countLow = StringConverters.ToInteger(((BasicDBObject) objectLow).get("count").toString());
                if (province.equals(provinceLow)) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("province", provinceLow);
                    jsonObject.put("num", count1 - countLow);
                    jsonObject.put("value1", count1);
                    jsonObject.put("value2", countLow);

                    jsonObjectList.add(jsonObject);
                    jsonArray.add(jsonObject);
                }
            }
        }
        Collections.sort(jsonObjectList, new Comparator<JSONObject>() {
            public int compare(JSONObject arg0, JSONObject arg1) {
                long hits0 = arg0.getInteger("num");
                long hits1 = arg1.getInteger("num");
                if (hits1 > hits0) {
                    return 1;
                } else if (hits1 == hits0) {
                    return 0;
                } else {
                    return -1;
                }
            }
        });
        title.put("title", jsonObjectList.get(0).getString("province"));
        JSONArray dataArray = new JSONArray();
        JSONObject dataObject1 = new JSONObject();
        dataObject1.put("name", "计划开店门店");
        dataObject1.put("value", jsonObjectList.get(0).getString("value1"));
        JSONObject dataObject2 = new JSONObject();
        dataObject2.put("name", "实际开店门店");
        dataObject2.put("value", jsonObjectList.get(0).getString("value2"));
        dataArray.add(dataObject1);
        dataArray.add(dataObject2);
        title.put("data", dataArray);

        line.add(title);

        graphic.put("line", line);
        shopObjectTotal.put("graphic", graphic);

        return shopObjectTotal;
    }

}
